package com.roc.web.action.reviseMerinfo;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;
import com.roc.util.constant.Role;

public class ReviseMerinfoSearchCondition extends BaseSearchCondition{
	
	private String opId;//操作人
	private String createDate;//创建日期
	private String batchNo;// 批次号

	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(createDate))
		{
			filedBeanList.add(new WhereHQLFieldBean(" substr (T.CREATEDATE,0,10)", createDate,"=", false));
		}
		if(Constance.isNotEmpty(batchNo))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.BATCH_NO", batchNo,"=", false));
		}
		
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT COUNT(1) FROM T_REVISE_MERINFO T ")
		  .append(" left join  tbl_mcht_inf a  on t.mcht_cd=a.mcht_cd ")
		  .append(" left join  tbl_term_inf b on b.mcht_cd=t.mcht_cd ")
		  .append(" left join  t_operators c on c.id=a.ext1 ")
		  .append(" left join tbl_dictionarylayeritem e on e.dic_code=(substr (a.UC_BC_CD_32,5,8) ) and e.dic_type='UnionPay_Area' and e.DIC_LEVEL>1 ")
		  .append(" where  1=1   ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT  ")
		  .append("  rownum, t.MCHT_CD ,b.TERM_ID,a.NAME,a.NAME_BUSI,a.UC_BC_CD_32,a.MCC_CD_18,c.real_name,  ")
		  .append(" (select op.real_name from  t_operators  op where  op.id= c.oneagentid ) oneAgent, a.BANK_BELONG_CD,")
		  .append(" (select op.REAL_NAME from t_operators op where op.id=c.COMPANYID ) companyName, ")
		  .append("  a.BUSI_LICE_NO,a.CERTIF,a.PROV_CD,a.CITY_CD,a.AREA_CD,a.REG_ADDR,  ")
		  .append("  e.name yu, a.CONTACT_NAME,a.CONTACT_PHONENO,to_char(a.REC_CRT_TS,'yyyyMMdd'), a.status , ")
		  .append(" (case a.status  when '03' then a.REC_UPD_TS    end  )  logout_date,  ")
		  .append("  t.CREATEDATE,t.batch_no   ")
		  .append("  FROM T_REVISE_MERINFO T ")
		  .append(" left join  tbl_mcht_inf a  on t.mcht_cd=a.mcht_cd ")
		  .append(" left join  tbl_term_inf b on b.mcht_cd=t.mcht_cd ")
		  .append(" left join  t_operators c on c.id=a.ext1 ")
		  .append(" left join tbl_dictionarylayeritem e on e.dic_code=(substr (a.UC_BC_CD_32,5,8) ) and e.dic_type='UnionPay_Area' and e.DIC_LEVEL>1  ")
		  .append(" where 1=1   ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return " ORDER BY t.CREATEDATE DESC,t.batch_no ASC ";
	}

	public String getOpId() {
		return opId;
	}

	public void setOpId(String opId) {
		this.opId = opId;
	}

	public String getCreateDate() {
		return createDate;
	}

	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}

	public String getBatchNo() {
		return batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

	

}
